<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1">
  <title>记忆课堂</title>
  <link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <style>
    #app {
      margin-top: 30px;
    }
    .adminLoginBox {
      position: absolute;
      top: 20%;
      left: 50%;
      transform: translate(-50%, 0);
    }
    .mb-15 {
      margin-bottom: 20px;
    }
    .hide {
      opacity: 0;
    }
  </style>
</head>
<body>
  
  <div id="app" class="clearfix container " :class"{'hide': logined}"> 
    
    <div class="adminLoginBox col-md-6 col-xs-10">
      <h3 class="text-center mb-20">管理员登陆</h3>
      <form action="" class="form-horizontal" @submit="adminLogin">
        <div class="form-group">
          <label for="" class="col-md-4 col-xs-4">管理员账号</label>
          <div class="col-md-8 col-xs-8">
            <input type="text" v-model="admin.user" class="form-control">
          </div>
        </div>
        <div class="form-group">
          <label for="" class="col-md-4 col-xs-4">管理员密码</label>
          <div class="col-md-8 col-xs-8">
            <input type="password" v-model="admin.password" class="form-control">
          </div>
        </div>
        <div class="col-md-4 col-md-offset-4 col-xs-4 col-xs-offset-4">
          <button class="btn btn-primary">登陆</button>
        </div>
      </form>
    </div>

  </div>



  <script type="text/javascript" src="/lib/vue/vue.min.js"></script>
  <script src="/lib/vue/vue-resource.min.js"></script>
  <script>

    Vue.use(VueResource)

    new Vue({
      el: '#app',
      data: {
        logined: false,
        admin: {
          user: '',
          password: ''
        },

      },
      methods: {
        adminLogin: function (ev) {
          ev.preventDefault()


          this.$http.get('/admin/login', {
            params: this.admin
          }).then(function (res) {
            if (res.data.code == 100) {
              this.logined = true
              sessionStorage.memoryClassAdmin = true
              location.href = 'http://' + location.host + '/admin'
            }
          })
        }
      }
    })

  </script>
</body>
</html>